package com.example.shardingsphere.repository;

import com.example.shardingsphere.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserRepository {
    User selectById(@Param("userId") Long userId);
    List<User> findAll();
    Integer insert(User user);

    /**
     *
     * @param loginName
     * @return
     */
    User findByEmailOrPhone(String loginName);

    /**
     * 超管 查询所有用户个数
     * @return
     */
    Long countAllUsers();

    /**
     * 超管 查询所有用户
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<User> selectAllUsers(int pageNum, int pageSize);

    // Mapper接口修改
    List<User> selectUsersByIds(
            @Param("normalUserIds") List<Long> normalUserIds,
            @Param("offset") int offset,
            @Param("pageSize") int pageSize);

    Integer updateUser(User user);

    User selectUserName(String username);

    User selectUsersByPhone(String phone);

    User selectUsersByEmail(String email);

    User select(Long userId);

}